WeaveClient
class is the primary interface for interacting with the Weave service. It provides methods for managing calls, datasets, models, and other Weave objects.
Constructor
Parameters
- project (
str
) - The project identifier in the format “entity/project”
Methods
add_cost
Add custom cost tracking to a call.Parameters
- costs (
Dict[str, float]
) - Dictionary of cost metrics (e.g.,{"prompt_tokens": 100, "completion_tokens": 50}
) - call_id (
Optional[str]
) - The call ID to add costs to. If None, uses the current call context.
Example
query_costs
Query costs for calls with various filters.purge_costs
Remove custom costs by their IDs.get_call
Retrieve a specific call by its ID.Parameters
- call_id (
str
) - The unique identifier of the call
Returns
- Call - A Call object containing the call details
Example
get_calls
Query multiple calls with filters.Parameters
- filter (
Optional[CallsFilter]
) - Filter criteria for calls - limit (
Optional[int]
) - Maximum number of calls to return - offset (
Optional[int]
) - Number of calls to skip
delete
Delete a call or calls.set_display_name
Set or update the display name of a call.Working with Datasets
save
Save a dataset to Weave.get
Retrieve a dataset by name.Working with Models
save
Save a model to Weave.get
Retrieve a model by reference.For complete examples and advanced usage, see the Weave documentation.